package cn.blunce.greendaoinandroidstudio.models;

import android.database.sqlite.SQLiteDatabase;

import java.util.Map;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.AbstractDaoSession;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import de.greenrobot.dao.internal.DaoConfig;

import cn.blunce.greendaoinandroidstudio.models.Person;
import cn.blunce.greendaoinandroidstudio.models.Job;

import cn.blunce.greendaoinandroidstudio.models.PersonDao;
import cn.blunce.greendaoinandroidstudio.models.JobDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * {@inheritDoc}
 * 
 * @see de.greenrobot.dao.AbstractDaoSession
 */
public class DaoSession extends AbstractDaoSession {

    private final DaoConfig personDaoConfig;
    private final DaoConfig jobDaoConfig;

    private final PersonDao personDao;
    private final JobDao jobDao;

    public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
            daoConfigMap) {
        super(db);

        personDaoConfig = daoConfigMap.get(PersonDao.class).clone();
        personDaoConfig.initIdentityScope(type);

        jobDaoConfig = daoConfigMap.get(JobDao.class).clone();
        jobDaoConfig.initIdentityScope(type);

        personDao = new PersonDao(personDaoConfig, this);
        jobDao = new JobDao(jobDaoConfig, this);

        registerDao(Person.class, personDao);
        registerDao(Job.class, jobDao);
    }
    
    public void clear() {
        personDaoConfig.getIdentityScope().clear();
        jobDaoConfig.getIdentityScope().clear();
    }

    public PersonDao getPersonDao() {
        return personDao;
    }

    public JobDao getJobDao() {
        return jobDao;
    }

}
